package com.tmsps.auto.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.tmsps.auto.action.Tip;
import com.tmsps.auto.action.Tip.Type;
import com.tmsps.auto.conf.SESSION_VAL;
import com.tmsps.auto.model.t_admin;


public class CPRoleCheckInterceptor extends HandlerInterceptorAdapter{

	@Override
	public boolean preHandle(HttpServletRequest req, HttpServletResponse resp,
			Object handler) throws Exception {
		t_admin ta = (t_admin) req.getSession().getAttribute(SESSION_VAL.ADMIN_INFO);
		if (ta == null) {
			Tip tip = new Tip();
			tip.setMsg("请登录在进行下一步操作!");
			tip.setType(Type.error);
			req.getSession().setAttribute("tip", tip);
			resp.sendRedirect(req.getContextPath() + "/logincp.htm");
			return false;
		}
		return true;
	}

}
